package com.ml.enums;

import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

@Getter
public enum EnumSymbol {

	BTC_USDT(0, "BTC", "USDT");

	private int code;

	private String one;

	private String two;

	private EnumSymbol(int code, String one, String two) {
		this.code = code;
		this.one = one;
		this.two = two;
	}

	public static Optional<EnumSymbol> of(int code) {
		return Arrays.stream(values()).filter(i -> i.code == code).findFirst();
	}

	public static EnumSymbol nameOf(String name) {
		Optional<EnumSymbol> optional = Arrays.stream(values()).filter(i -> name.equals(i.one + i.two)).findFirst();
		return optional.orElse(null);
	}
}
